<template>
    <div class="bottom-tab">
        <div class="tab-item" @click="switchTo('/')">
            <img
                :src="'/' === $route.path ? tabBarImgArr[0].selected : tabBarImgArr[0].normal"
                alt="首页"
            />
            <span :class="{on: '/' === $route.path}">首页</span>
        </div>
        <div class="tab-item" @click="switchTo('/source')">
            <img
                :src="'/source' === $route.path ? tabBarImgArr[1].selected : tabBarImgArr[1].normal"
                alt="房源"
            />
            <span :class="{on: '/source' === $route.path}">房源</span>
        </div>
        <div class="tab-item" @click="switchTo('/sto')">
            <img
                :src="'/sto' === $route.path ? tabBarImgArr[2].selected : tabBarImgArr[2].normal"
                alt="ETO"
            />
            <span :class="{on: '/sto' === $route.path}">ETO</span>
        </div>
        <!-- <div class="tab-item" @click="switchTo('/c2c')">
            <img
                :src="'/c2c' === $route.path ? tabBarImgArr[3].selected : tabBarImgArr[3].normal"
                alt="C2C"
            />
            <span :class="{on: '/c2c' === $route.path}">C2C</span>
        </div> -->
    </div>
</template>
<script>
export default {
    data() {
        return {
            tabBarImgArr: [
                //图片切换
                {
                    normal: require("../../assets/img/shouye.png"),
                    selected: require("../../assets/img/shouyeLight.png")
                },
                {
                    normal: require("../../assets/img/fangyuan.png"),
                    selected: require("../../assets/img/fangyuanLight.png")
                },
                {
                    normal: require("../../assets/img/ETO.png"),
                    selected: require("../../assets/img/ETOLight.png")
                },
                {
                    normal: require("../../assets/img/OTC.png"),
                    selected: require("../../assets/img/OTCLight.png")
                }
            ]
        };
    },
    methods: {
        switchTo(path) {
            // console.log(this.$router)
            this.$router.replace(path);
        }
    }
};
</script>

<style lang="less" scoped>
.bottom-tab {
    width: 100%;
    height: 8vh;
    background-color: #fff;
    position: fixed;
    left: 0px;
    bottom: 0px;
    display: flex;
    z-index: 1;
    border-top: 1px solid #efefef;
    box-sizing: border-box;
}

.tab-item {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    color: @blackColor5;
    text-align: center;
    >img{
        flex: 1;
        width: 25px;
        height: 25px;
    }
    >span{
        flex: 1;
        padding-left: 5px;
        font-size: 12px;
        margin-top: 3px;
    }
}

/deep/.on {
    color: rgba(102, 102, 102, 1);
    padding-top: -10px;
    font-size: 13px;
    font-family: PingFang-SC-Regular;
    font-weight: 400;
    color: rgba(56, 83, 118, 1);
}
/deep/span {
    margin-left: -5px;
    font-size: 13px;
    margin-top: 7px;
    padding-bottom: 4px;
}
/deep/img {
    width: 25px;
    height: 25px;
    margin-top: 4px;
}
</style>